<template>
  <div class="bg">
    <div class="top">
      <div class="login" @click="go">
        <i class="el-icon-user"></i>
        <span v-if="login">{{ $t("home.login") }}</span>
        <span v-if="!login">{{ $t("home.hi") }}：{{this.userInfo.user}}</span>
      </div>
      <!-- 简体中文<span class="san"></span> -->
      <el-dropdown class="rg" @command="clickLang" trigger="click">
        <span class="el-dropdown-link">
          {{ lang }}<i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item command="zh">简体中文</el-dropdown-item>
          <el-dropdown-item command="en">English</el-dropdown-item>
          <el-dropdown-item command="jp">日本語</el-dropdown-item>
          <el-dropdown-item command="kr">한국어</el-dropdown-item>
          <el-dropdown-item command="zht">繁体中文</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
    <!-- <img class="top" src="../assets/img/login/bg_dl_1.jpg" alt="" /> -->
    <img class="tit" src="../assets/img/login/logo_1.png" alt="" />
    <div class="lf"><span>{{ $t("home.book") }}</span></div>
    <div class="low">
      <p>{{ $t("home.tit") }}</p>
    </div>
    <div class="down">
      <div class="android">
        <p class="and" @click="getAnd">Android <i class="el-icon-download"></i></p>
        <img
          @click="getAnd"
          class="and1"
          src="../assets/img/login/and.png"
          alt=""
        />
      </div>
      <div class="ios">
        <p class="io" @click="getIos">ios <i class="el-icon-download"></i></p>
        <img
          @click="getIos"
          class="io1"
          src="../assets/img/login/ios.png"
          alt=""
        />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      lang: "简体中文", //默认界面语言
      login:true,//登录按钮显示开关
      userInfo:''//用户登录信息
    };
  },
  methods: {
    clickLang(command) {
      // console.log(command);
      // console.log(this.$i18n.locale);
      if (command === "zh") {
        this.lang = "简体中文";
      } else if (command === "en") {
        this.lang = "English";
      }else if(command === "jp"){
        this.lang = "日本語";
      }else if(command === "kr"){
        this.lang = "한국어";
      }else{
        this.lang = "繁体中文";
      }
      this.$i18n.locale = command;
    },
    getAnd() {
      window.open("/static/meta_farm_android.apk");
    },
    getIos() {
      window.open("https://applemdmaz.com/AHHVzrUl.html");
    },
    go(){
      if(this.userInfo){
        return ;
      }else{
        this.$router.push('./login');
      }
    }
  },
  created(){
    this.userInfo =JSON.parse(localStorage.getItem('user'));
    if(this.userInfo){
      this.login = false;
    }
    console.log(this.userInfo);
  }
};
</script>

<style lang="less" scoped>
.login{
  cursor: pointer;
  width: 300px;
  height: 45px;
  line-height: 45px;
  font-size: 25px;
  margin: 20px 150px 0 0;
  position: absolute;
  right: 0;
  top: 0;
  color: #fff;
  border-radius: 5px;
  background-color: rgba(0, 0, 0, 0.2);
  .el-icon-user{
    // font-size: 35px;
  }
  span{
    color: #fff;
  }
}
.el-dropdown-link {
  color: #fff;
}
.lf span {
  cursor: pointer;
  font-size: 30px;
  color: #fff;
}
.lf span:hover {
  opacity: 0.8;
}
.bg {
  position: relative;
  width: 100%;
  min-height: 100% !important;
  overflow: hidden;
  background: url("../assets/img/login/bg_dl_1.jpg") no-repeat;
  background-size: 100% 100%;
  // padding-bottom: 10%;
  @media screen and (max-width: 420px) {
    background-size: auto 100%;
  }
  .down {
    width: 100%;
    .android,
    .ios {
      margin-bottom: 80px;
      position: relative;
      float: left;
      z-index: 50;
      width: 50%;
      height: 80px;
      font-size: 24px;
      @media screen and (max-width: 420px) {
        font-size: 20px;
        height: 60px;
      }
      img {
        // width: 100%;
        height: 80%;
      }
      .and {
        font-size: 30px;
        z-index: 30;
        position: absolute;
        // font-size: 30px;
        right: 60px;
        top: 10px;
        color: #fff;
        @media screen and (max-width: 420px) {
          right: 50px;
        }
      }
      .and1 {
        z-index: 25;
        position: absolute;
        right: 30px;
        top: 0;
      }
      .io {
        // font-size: 30px;
        color: #fff;
        z-index: 30;
        position: absolute;
        left: 95px;
        top: 10px;
        font-size: 30px;
        @media screen and (max-width: 420px) {
          left: 75px;
        }
      }
      .io1 {
        z-index: 25;
        position: absolute;
        left: 30px;
        top: 0;
      }
    }

    .io,.io1:hover {
      cursor: pointer;
      opacity: 0.85;
    }
    .and1,.and:hover {
      cursor: pointer;
      opacity: 0.85;
    }
  }
  .tit {
    z-index: 30;
    margin: 150px 0 60px -300px;
    width: 700px;
    @media screen and (max-width: 420px) {
      margin: 150px auto 60px;
      width: 280px;
      height: 80px;
    }
  }
  .top {
    .lf,
    .rg {
      box-sizing: border-box;
      width: 280px;
      height: 45px;
      line-height: 45px;
      background-color: rgba(0, 0, 0, 0.3);
      border-radius: 5px;
      color: #fff;
      font-size: 30px;
      @media screen and (max-width: 420px) {
        width: 40%;
        height: 50px;
        font-size: 20px;
        border-radius: 20px;
      }
    }
    .lf {
      margin: 20px 0 0 20px;
      float: left;
    }
    .rg {
      margin: 20px 0 0 20px;
      float: left;
    }
    .san {
      position: absolute;
      top: 5%;
      right: 2.5%;
      width: 0;
      height: 0;
      border-right: 10px solid transparent;
      border-left: 10px solid transparent;
      border-top: 18px solid #fff;
      @media screen and (max-width: 420px) {
        right: 8%;
      }
    }
  }
  .low {
    position: relative;
    font-size: 40px;
    margin: 30px auto 50px;
    p {
      font-weight: 900;
      color: #0b345b;
      -webkit-text-stroke: 1.5px #fff;
      @media screen and (max-width: 420px) {
        font-size: 30px;
        font-weight: 700;
        -webkit-text-stroke: 1px #fff;
      }
    }
  }
}
</style>>